<%@ page import="cn.tedu.web.stm.JdbcUtils" %>
<%@ page import="cn.tedu.web.stm.homework.User" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%
    String id = request.getParameter("id");
    User user=null;
    if(id!=null){
        String sql="SELECT `id`,`name`,username,`password` FROM `user` WHERE id=?";
        user = JdbcUtils.select(sql, User.class, id);
    }
    if(user==null){
        user =new User();
        user.setName("");
        user.setUsername("");
        user.setPassword("");
    }
%>
<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Java实训团队协作简单案例 - 用户信息编辑页面</title>
    <link rel="shortcut icon" href="assets/img/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="assets/vendors/font-awesome-4.7.0/css/font-awesome.min.css" />
    <link rel="stylesheet" href="assets/css/core.css" />
    <link rel="stylesheet" href="assets/css/index.css" />

    <link rel="stylesheet" href="assets/css/user.css" />
</head>

<body>
    <jsp:include page="/WEB-INF/tpl/stm/header.jsp"/>
    <section class="container">
        <jsp:include page="/WEB-INF/tpl/stm/side.jsp"/>
        <div class="main-right">
            <h3>用户信息编辑页面</h3>
            <form action="/stm/insert">
                <div>
                    <label>姓名：</label>
                    <input type="text" name="name" value="<%=user.getName()%>"/>
                </div>
                <div>
                    <label>账号：</label>
                    <input type="text" name="username" value="<%=user.getUsername()%>"/>
                </div>
                <div>
                    <label>密码：</label>
                    <input type="password" name="password" value="<%=user.getPassword()%>"/>
                </div>
                <div>
                    <button type="submit" style="padding: 9px 14px;font-size: 15px;line-height: normal;border-radius: 5px;margin: 20px 80px;">保存</button>
                </div>
                <input name="id" type="hidden" value="<%=id%>" />
            </form>
        </div>
    </section>
</body>

</html>